from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib.sites.models import Site
from tagging.views import tagged_object_list
from models import Document

site = Site.objects.get(id=settings.SITE_ID)

info_dict = {
    'queryset': Document.published_objects.filter(site = settings.SITE_ID),
    'date_field': 'pub_date',
}

urlpatterns = patterns ('',
    # Add/Edit views
    (r'^add/$', 'clapton.apps.documents.views.add_edit_document'),
    (r'^edit/$', 'clapton.apps.documents.views.add_edit_document'),

    # Tag view
    (r'tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,
     dict(model = Document, paginate_by = 10, allow_empty = True)),

    # Date-based views
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'django.views.generic.date_based.object_detail', 
     dict (info_dict, slug_field = 'slug', extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', dict(info_dict, extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month', 
     dict(info_dict, extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/$', 'django.views.generic.date_based.archive_year',
     dict(info_dict, make_object_list = True, extra_context={'site': site,})),
    (r'^today/$', 'django.views.generic.date_based.archive_today', dict(info_dict, extra_context={'site': site,})),

    # Archive Index
    (r'^/?$', 'django.views.generic.date_based.archive_index', dict(info_dict, extra_context={'site': site,})),
)
